package com.hrbxlh.util;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;



public class PropertiesUtil {

	// 接口文件
	public static String[] getUrl(String[] interfaceNameArr) {
		Map<String, String> returnMap = new HashMap<String, String>();
		String[] valueArr = new String[interfaceNameArr.length];
		String filename = "UtilFile.properties";
		try (InputStream inputStream = PropertiesUtil.class.getClassLoader()
				.getResourceAsStream(filename)){
					Properties props = new Properties();
			props.load(inputStream);
			Iterator<String> it = props.stringPropertyNames().iterator();
			while (it.hasNext()) {
				String key = it.next();
				for (String interfaceName : interfaceNameArr) {
					if (interfaceName.equals(key)) {
						returnMap.put(key, props.getProperty(key));
					}
				}
			}
			int index = 0;

			for (String interfaceName : interfaceNameArr) {
				for (Map.Entry<String, String> entry : returnMap.entrySet()) {
					if (interfaceName.equals(entry.getKey())) {
						valueArr[index] = entry.getValue();
						index++;
						break;
					}
					if (index == interfaceNameArr.length) {
						break;
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return valueArr;
	}
}
